package com.ikun.admin.modules.gen.controller;

import com.ikun.admin.modules.gen.iservice.IMenuService;
import com.ikun.admin.modules.gen.vo.MenuAddOrUpdateVo;
import com.ikun.admin.modules.gen.vo.MenuDictVo;
import com.ikun.admin.modules.gen.vo.MenuTreeVo;
import com.ikun.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName MenuController
 * @Description:
 * @CreateDate: 2024/8/12 23:22
 */
@RestController
@RequestMapping("/develop/menu")
@Api(tags = "菜单管理")
public class MenuController {

    @Autowired
    private IMenuService iMenuService;

    @GetMapping("/menu/tree/API_001")
    @ApiOperation("获取菜单树")
    public Result<List<MenuTreeVo>> menuTree(){
        return iMenuService.menuTree();
    }
    @GetMapping("/menu/select/API_002/{id}")
    @ApiOperation("查询详情")
    public Result<MenuAddOrUpdateVo> menuDetail(@PathVariable Long id){
        return iMenuService.menuDetail(id);
    }

    @PostMapping("/menu/addOrUpdate/API_003")
    @ApiOperation("添加或修改菜单")
    public Result<String> addOrUpdateMenu(@RequestBody MenuAddOrUpdateVo menuAddOrUpdateVo){
        return iMenuService.addOrUpdateMenu(menuAddOrUpdateVo);
    }
    @GetMapping("/menu/tree/API_003/{type}")
    @ApiOperation("根据权限或者菜单类型 查询所有上级菜单 树形结构")
    public Result<List<MenuDictVo>> menuDictList(@PathVariable Integer type){
        return iMenuService.menuDictList(type);
    }
    @DeleteMapping("/menu/delete/API_004/{id}")
    @ApiOperation("删除菜单")
    public Result<String> menuDelete(@PathVariable Long id){
        return iMenuService.menuDelete(id);
    }


}


